```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>设计模式精要指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .heading-serif {
            font-family: 'Noto Serif SC', serif;
        }
        .code-block {
            background-color: #f8f8f8;
            border-left: 4px solid #42b983;
            color: #525252;
            padding: 1em;
            margin: 1.5em 0;
            overflow-x: auto;
        }
        .pattern-card {
            transition: all 0.3s ease;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .pattern-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .nav-link {
            position: relative;
        }
        .nav-link:after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            bottom: 0;
            left: 0;
            background-color: #667eea;
            transition: width 0.3s ease;
        }
        .nav-link:hover:after {
            width: 100%;
        }
        .active-nav:after {
            width: 100%;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- 导航栏 -->
    <nav class="bg-white shadow-md sticky top-0 z-50">
        <div class="container mx-auto px-6 py-4">
            <div class="flex justify-between items-center">
                <a href="#" class="text-xl font-bold text-gray-800 heading-serif">设计模式指南</a>
                <div class="hidden md:flex space-x-8">
                    <a href="#creational" class="nav-link text-gray-700 hover:text-indigo-600">创建型</a>
                    <a href="#structural" class="nav-link text-gray-700 hover:text-indigo-600">结构型</a>
                    <a href="#behavioral" class="nav-link text-gray-700 hover:text-indigo-600">行为型</a>
                </div>
                <button class="md:hidden text-gray-600">
                    <i class="fas fa-bars text-2xl"></i>
                </button>
            </div>
        </div>
    </nav>

    <!-- Hero 区域 -->
    <section class="hero-gradient text-white py-20 md:py-32">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-4xl md:text-6xl font-bold mb-6 heading-serif">设计模式精要指南</h1>
            <p class="text-xl md:text-2xl max-w-3xl mx-auto mb-10">探索23种经典设计模式，提升代码质量与系统架构能力</p>
            <div class="flex justify-center space-x-4">
                <a href="#creational" class="bg-white text-indigo-600 px-8 py-3 rounded-full font-semibold hover:bg-gray-100 transition duration-300">开始学习</a>
                <a href="#mermaid-chart" class="border-2 border-white text-white px-8 py-3 rounded-full font-semibold hover:bg-white hover:text-indigo-600 transition duration-300">模式关系图</a>
            </div>
        </div>
    </section>

    <!-- 简介部分 -->
    <section class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto">
                <h2 class="text-3xl font-bold mb-6 heading-serif">设计模式：软件开发的基石</h2>
                <p class="text-lg mb-6">设计模式是软件开发中的一种经验总结，它提供了解决常见设计问题的最佳实践。这些模式可以解决各种设计问题和挑战，帮助开发人员编写更灵活、可维护和扩展的代码。</p>
                <p class="text-lg">了解这些模式及其应用场景对于高效的软件设计和开发至关重要。设计模式通常分为三大类：创建型模式、结构型模式和行为型模式，每一类都针对特定的设计问题提供了优雅的解决方案。</p>
            </div>
        </div>
    </section>

    <!-- 创建型模式 -->
    <section id="creational" class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <span class="text-indigo-600 font-semibold">创建型模式</span>
                <h2 class="text-3xl font-bold mt-2 heading-serif">对象创建的优雅之道</h2>
                <p class="max-w-2xl mx-auto mt-4 text-gray-600">这些设计模式提供了一种在创建对象的同时隐藏创建逻辑的方式，而不是直接使用 new 运算符实例化对象。</p>
            </div>

            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
                <!-- 单例模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-indigo-100 p-3 rounded-full mr-4">
                            <i class="fas fa-cube text-indigo-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">单例模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>确保一个类只有一个实例，并提供全局访问点。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>数据库连接池、线程池、配置管理等。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>public class Singleton {
    private static Singleton instance;
    
    private Singleton() {}
    
    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-indigo-100 text-indigo-800 px-2 py-1 rounded">创建型</span>
                    </div>
                </div>

                <!-- 工厂方法模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-industry text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">工厂方法模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>定义一个创建对象的接口，但让子类决定实例化哪个类。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>需要创建对象但不希望知道具体类的实现。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Product {
    void create();
}

class ConcreteProductA implements Product {
    public void create() {
        System.out.println("Product A");
    }
}

abstract class Creator {
    public abstract Product factoryMethod();
}

class ConcreteCreatorA extends Creator {
    public Product factoryMethod() {
        return new ConcreteProductA();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">创建型</span>
                    </div>
                </div>

                <!-- 抽象工厂模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-building text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">抽象工厂模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>提供一个创建一系列相关或相互依赖对象的接口。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当系统需要独立于产品的创建、组合和表示时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface AbstractFactory {
    ProductA createProductA();
    ProductB createProductB();
}

class ConcreteFactory1 implements AbstractFactory {
    public ProductA createProductA() {
        return new ProductA1();
    }
    public ProductB createProductB() {
        return new ProductB1();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-purple-100 text-purple-800 px-2 py-1 rounded">创建型</span>
                    </div>
                </div>

                <!-- 建造者模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 p-3 rounded-full mr-4">
                            <i class="fas fa-hammer text-green-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">建造者模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>使用多个简单的对象一步步构建成一个复杂的对象。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当创建一个复杂对象的过程应该独立于该对象的组成部分和表示时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>class Product {
    private String part1;
    private String part2;
    
    public void setPart1(String part1) { this.part1 = part1; }
    public void setPart2(String part2) { this.part2 = part2; }
}

abstract class Builder {
    protected Product product = new Product();
    public abstract void buildPart1();
    public abstract void buildPart2();
    public Product getResult() { return product; }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">创建型</span>
                    </div>
                </div>

                <!-- 原型模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-yellow-100 p-3 rounded-full mr-4">
                            <i class="fas fa-clone text-yellow-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">原型模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>通过复制已有的实例来创建新实例，而不是通过新建。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当创建对象的成本高于复制对象的成本时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Prototype extends Cloneable {
    Prototype clone();
}

class ConcretePrototype implements Prototype {
    public Prototype clone() {
        try {
            return (Prototype) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">创建型</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 结构型模式 -->
    <section id="structural" class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <span class="text-indigo-600 font-semibold">结构型模式</span>
                <h2 class="text-3xl font-bold mt-2 heading-serif">类和对象的组合艺术</h2>
                <p class="max-w-2xl mx-auto mt-4 text-gray-600">这些设计模式关注类和对象的组合。继承的概念被用来组合接口和定义组合对象获得新功能的方式。</p>
            </div>

            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
                <!-- 适配器模式 -->
                <div class="pattern-card bg-white p-6 border border-gray-100">
                    <div class="flex items-center mb-4">
                        <div class="bg-red-100 p-3 rounded-full mr-4">
                            <i class="fas fa-exchange-alt text-red-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">适配器模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>将一个类的接口转换成客户希望的另一个接口。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要将一个接口适配成客户端期望的另一个接口时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Target {
    void request();
}

class Adaptee {
    public void specificRequest() {
        System.out.println("Specific request");
    }
}

class Adapter implements Target {
    private Adaptee adaptee;
    
    public Adapter(Adaptee adaptee) {
        this.adaptee = adaptee;
    }
    
    public void request() {
        adaptee.specificRequest();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-red-100 text-red-800 px-2 py-1 rounded">结构型</span>
                    </div>
                </div>

                <!-- 桥接模式 -->
                <div class="pattern-card bg-white p-6 border border-gray-100">
                    <div class="flex items-center mb-4">
                        <div class="bg-indigo-100 p-3 rounded-full mr-4">
                            <i class="fas fa-bridge text-indigo-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">桥接模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>将抽象部分与实现部分分离，使它们可以独立地变化。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要在抽象和实现之间进行不同的组合时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Implementor {
    void operation();
}

abstract class Abstraction {
    protected Implementor implementor;
    
    protected Abstraction(Implementor implementor) {
        this.implementor = implementor;
    }
    
    public abstract void operation();
}

class RefinedAbstraction extends Abstraction {
    public RefinedAbstraction(Implementor implementor) {
        super(implementor);
    }
    
    public void operation() {
        implementor.operation();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-indigo-100 text-indigo-800 px-2 py-1 rounded">结构型</span>
                    </div>
                </div>

                <!-- 组合模式 -->
                <div class="pattern-card bg-white p-6 border border-gray-100">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 p-3 rounded-full mr-4">
                            <i class="fas fa-sitemap text-green-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">组合模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>将对象组合成树形结构以表示"部分-整体"的层次结构。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要处理部分和整体的关系时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Component {
    void operation();
}

class Leaf implements Component {
    public void operation() {
        System.out.println("Leaf");
    }
}

class Composite implements Component {
    private List<Component> children = new ArrayList<>();
    
    public void add(Component component) {
        children.add(component);
    }
    
    public void operation() {
        for (Component child : children) {
            child.operation();
        }
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">结构型</span>
                    </div>
                </div>

                <!-- 装饰器模式 -->
                <div class="pattern-card bg-white p-6 border border-gray-100">
                    <div class="flex items-center mb-4">
                        <div class="bg-yellow-100 p-3 rounded-full mr-4">
                            <i class="fas fa-paint-brush text-yellow-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">装饰器模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>动态地给一个对象添加一些额外的职责。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要动态地为对象添加功能时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Component {
    void operation();
}

class ConcreteComponent implements Component {
    public void operation() {
        System.out.println("Concrete Component");
    }
}

abstract class Decorator implements Component {
    protected Component component;
    
    public Decorator(Component component) {
        this.component = component;
    }
    
    public void operation() {
        component.operation();
    }
}

class ConcreteDecorator extends Decorator {
    public ConcreteDecorator(Component component) {
        super(component);
    }
    
    public void operation() {
        super.operation();
        System.out.println("Concrete Decorator");
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-yellow-100 text-yellow-800 px-2 py-1 rounded">结构型</span>
                    </div>
                </div>

                <!-- 外观模式 -->
                <div class="pattern-card bg-white p-6 border border-gray-100">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-door-open text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">外观模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>为子系统中的一组接口提供一个一致的界面。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要简化复杂系统的接口时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>class SubsystemA {
    public void operationA() {
        System.out.println("Subsystem A");
    }
}

class Facade {
    private SubsystemA subsystemA = new SubsystemA();
    
    public void operation() {
        subsystemA.operationA();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">结构型</span>
                    </div>
                </div>

                <!-- 享元模式 -->
                <div class="pattern-card bg-white p-6 border border-gray-100">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-feather-alt text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">享元模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>运用共享技术有效地支持大量细粒度的对象。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要支持大量的对象，且这些对象的个体不重要时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Flyweight {
    void operation();
}

class ConcreteFlyweight implements Flyweight {
    public void operation() {
        System.out.println("Concrete Flyweight");
    }
}

class FlyweightFactory {
    private Map<String, Flyweight> flyweights = new HashMap<>();
    
    public Flyweight getFlyweight(String key) {
        Flyweight flyweight = flyweights.get(key);
        if (flyweight == null) {
            flyweight = new ConcreteFlyweight();
            flyweights.put(key, flyweight);
        }
        return flyweight;
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-purple-100 text-purple-800 px-2 py-1 rounded">结构型</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 行为型模式 -->
    <section id="behavioral" class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <span class="text-indigo-600 font-semibold">行为型模式</span>
                <h2 class="text-3xl font-bold mt-2 heading-serif">对象间的优雅协作</h2>
                <p class="max-w-2xl mx-auto mt-4 text-gray-600">这些设计模式特别关注对象之间的通信，以及责任在对象间的分配。</p>
            </div>

            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
                <!-- 观察者模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-pink-100 p-3 rounded-full mr-4">
                            <i class="fas fa-bell text-pink-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">观察者模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>定义对象间的一对多依赖，让多个观察者对象同时监听某一个主题对象。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当一个对象的状态变化需要通知多个其他对象时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Observer {
    void update(String message);
}

class Subject {
    private List<Observer> observers = new ArrayList<>();
    
    public void addObserver(Observer observer) {
        observers.add(observer);
    }
    
    public void notifyObservers(String message) {
        for (Observer observer : observers) {
            observer.update(message);
        }
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-pink-100 text-pink-800 px-2 py-1 rounded">行为型</span>
                    </div>
                </div>

                <!-- 策略模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-indigo-100 p-3 rounded-full mr-4">
                            <i class="fas fa-chess-knight text-indigo-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">策略模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>定义一系列算法，将每一个算法封装起来，并使它们可以互换。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要在多个算法之间进行切换时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Strategy {
    void execute();
}

class ConcreteStrategyA implements Strategy {
    public void execute() {
        System.out.println("Strategy A");
    }
}

class Context {
    private Strategy strategy;
    
    public void setStrategy(Strategy strategy) {
        this.strategy = strategy;
    }
    
    public void executeStrategy() {
        strategy.execute();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-indigo-100 text-indigo-800 px-2 py-1 rounded">行为型</span>
                    </div>
                </div>

                <!-- 模板方法模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-clipboard-list text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">模板方法模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>定义一个算法的骨架，而将一些步骤延迟到子类中。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当一个算法的结构不变，而某些步骤可以变时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>abstract class AbstractClass {
    public void templateMethod() {
        step1();
        step2();
        step3();
    }
    
    protected abstract void step1();
    protected abstract void step2();
    
    private void step3() {
        System.out.println("Step 3");
    }
}

class ConcreteClass extends AbstractClass {
    protected void step1() {
        System.out.println("ConcreteClass Step 1");
    }
    protected void step2() {
        System.out.println("ConcreteClass Step 2");
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded">行为型</span>
                    </div>
                </div>

                <!-- 命令模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-red-100 p-3 rounded-full mr-4">
                            <i class="fas fa-terminal text-red-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">命令模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>将请求封装成一个对象，从而使您可以使用不同的请求、队列请求或日志请求。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要将请求封装为对象，以便通过队列、日志等方式处理时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface Command {
    void execute();
}

class ConcreteCommand implements Command {
    private Receiver receiver;
    
    public ConcreteCommand(Receiver receiver) {
        this.receiver = receiver;
    }
    
    public void execute() {
        receiver.action();
    }
}

class Invoker {
    private Command command;
    
    public void setCommand(Command command) {
        this.command = command;
    }
    
    public void executeCommand() {
        command.execute();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-red-100 text-red-800 px-2 py-1 rounded">行为型</span>
                    </div>
                </div>

                <!-- 状态模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 p-3 rounded-full mr-4">
                            <i class="fas fa-toggle-on text-green-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">状态模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>允许一个对象在其内部状态改变时改变它的行为。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当对象的行为依赖于它的状态，并且它必须在运行时改变其行为时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>interface State {
    void handle();
}

class ConcreteStateA implements State {
    public void handle() {
        System.out.println("State A");
    }
}

class Context {
    private State state;
    
    public void setState(State state) {
        this.state = state;
    }
    
    public void request() {
        state.handle();
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-green-100 text-green-800 px-2 py-1 rounded">行为型</span>
                    </div>
                </div>

                <!-- 责任链模式 -->
                <div class="pattern-card bg-white p-6">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-link text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="text-xl font-bold heading-serif">责任链模式</h3>
                    </div>
                    <p class="text-gray-600 mb-4"><strong>定义：</strong>为请求创建一个接收者链。将请求沿着链传递，直到链上的某个对象处理它。</p>
                    <p class="text-gray-600 mb-4"><strong>应用场景：</strong>当需要将请求发送到一系列对象中，以决定哪个对象能处理请求时。</p>
                    <div class="code-block text-sm mb-4">
                        <pre>abstract class Handler {
    private Handler successor;
    
    public void setSuccessor(Handler successor) {
        this.successor = successor;
    }
    
    public void handleRequest(int request) {
        if (successor != null) {
            successor.handleRequest(request);
        }
    }
}

class ConcreteHandlerA extends Handler {
    public void handleRequest(int request) {
        if (request < 10) {
            System.out.println("Handler A handled request: " + request);
        } else {
            super.handleRequest(request);
        }
    }
}</pre>
                    </div>
                    <div class="flex justify-end">
                        <span class="text-xs bg-purple-100 text-purple-800 px-2 py-1 rounded">行为型</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 模式关系图 -->
    <section id="mermaid-chart" class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold heading-serif">设计模式关系图谱</h2>
                <p class="max-w-2xl mx-auto mt-4 text-gray-600">探索23种设计模式之间的关系与分类</p>
            </div>
            <div class="bg-gray-50 p-6 rounded-lg">
                <div class="mermaid">
                    graph TD
                    A[设计模式] --> B[创建型模式]
                    A --> C[结构型模式]
                    A --> D[行为型模式]
                    
                    B --> B1[单例模式]
                    B --> B2[工厂方法模式]
                    B --> B3[抽象工厂模式]
                    B --> B4[建造者模式]
                    B --> B5[原型模式]
                    
                    C --> C1[适配器模式]
                    C --> C2[桥接模式]
                    C --> C3[组合模式]
                    C --> C4[装饰器模式]
                    C --> C5[外观模式]
                    C --> C6[享元模式]
                    
                    D --> D1[观察者模式]
                    D --> D2[策略模式]
                    D --> D3[模板方法模式]
                    D --> D4[命令模式]
                    D --> D5[状态模式]
                    D --> D6[责任链模式]
                    
                    style A fill:#4F46E5,color:#fff,stroke:#4338CA
                    style B fill:#6366F1,color:#fff,stroke:#4F46E5
                    style C fill:#6366F1,color:#fff,stroke:#4F46E5
                    style D fill:#6366F1,color:#fff,stroke:#4F46E5
                    
                    style B1 fill:#ECFDF5,stroke:#10B981
                    style B2 fill:#ECFDF5,stroke:#10B981
                    style B3 fill:#ECFDF5,stroke:#10B981
                    style B4 fill:#ECFDF5,stroke:#10B981
                    style B5 fill:#ECFDF5,stroke:#10B981
                    
                    style C1 fill:#EFF6FF,stroke:#3B82F6
                    style C2 fill:#EFF6FF,stroke:#3B82F6
                    style C3 fill:#EFF6FF,stroke:#3B82F6
                    style C4 fill:#EFF6FF,stroke:#3B82F6
                    style C5 fill:#EFF6FF,stroke:#3B82F6
                    style C6 fill:#EFF6FF,stroke:#3B82F6
                    
                    style D1 fill:#FEF2F2,stroke:#EF4444
                    style D2 fill:#FEF2F2,stroke:#EF4444
                    style D3 fill:#FEF2F2,stroke:#EF4444
                    style D4 fill:#FEF2F2,stroke:#EF4444
                    style D5 fill:#FEF2F2,stroke:#EF4444
                    style D6 fill:#FEF2F2,stroke:#EF4444
                </div>
            </div>
        </div>
    </section>

    <!-- 总结 -->
    <section class="py-16 bg-gradient-to-r from-indigo-500 to-purple-600 text-white">
        <div class="container mx-auto px-6 text-center">
            <h2 class="text-3xl font-bold mb-6 heading-serif">掌握设计模式，提升编程艺术</h2>
            <p class="text-xl max-w-3xl mx-auto mb-8">设计模式是软件开发中的宝贵财富，理解并恰当运用这些模式可以显著提高代码质量、可维护性和可扩展性。</p>
            <div class="flex flex-wrap justify-center gap-6 mb-10">
                <div class="bg-white bg-opacity-10 p-4 rounded-lg backdrop-blur-sm">
                    <i class="fas fa-cubes text-3xl mb-3"></i>
                    <h3 class="font-bold text-lg">创建型模式</h3>
                    <p class="text-sm opacity-90">5种模式</p>
                </div>
                <div class="bg-white bg-opacity-10 p-4 rounded-lg backdrop-blur-sm">
                    <i class="fas fa-project-diagram text-3xl mb-3"></i>
                    <h3 class="font-bold text-lg">结构型模式</h3>
                    <p class="text-sm opacity-90">7种模式</p>
                </div>
                <div class="bg-white bg-opacity-10 p-4 rounded-lg backdrop-blur-sm">
                    <i class="fas fa-people-arrows text-3xl mb-3"></i>
                    <h3 class="font-bold text-lg">行为型模式</h3>
                    <p class="text-sm opacity-90">11种模式</p>
                </div>
            </div>
            <a href="#" class="inline-block bg-white text-indigo-600 px-8 py-3 rounded-full font-semibold hover:bg-gray-100 transition duration-300">返回顶部</a>
        </div>
    </section>

    <!-- 页脚 -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto px-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white heading-serif">技术小馆</h3>
                    <p class="mt-2">探索编程艺术与架构之美</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-globe mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-sm">
                <p>© 2023 技术小馆. 版权所有.</p>
            </div>
        </div>
    </footer>

    <script>
        // 初始化Mermaid图表
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });

        // 当前导航高亮
        window.addEventListener('scroll', function() {
            const sections = document.querySelectorAll('section');
            const navLinks = document.querySelectorAll('.nav-link');
            
            let current = '';
            sections.forEach(section => {
                const sectionTop = section.offsetTop;
                const sectionHeight = section.clientHeight;
                if (pageYOffset >= sectionTop - 200) {
                    current = section.getAttribute('id');
                }
            });
            
            navLinks.forEach(link => {
                link.classList.remove('active-nav');
                if (link.getAttribute('href') === `#${current}`) {
                    link.classList.add('active-nav');
                }
            });
        });
    </script>
</body>
</html>
```